From 80dd4837042ef7b8600f63b0a75e89cef44b491f Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 14 Jul 2003 23:35:29 +0000 Subject: [PATCH] bitkeeper revision 1.339.1.13 (3f133e41JY3T8AGVWEoFdVWiKkJdvQ) xeno.c: Fix Xenolinux to mark protected disc partitions as read-only. --- xenolinux-2.4.21-sparse/fs/partitions/xeno.c | 63 ++++++++++---------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/xenolinux-2.4.21-sparse/fs/partitions/xeno.c b/xenolinux-2.4.21-sparse/fs/partitions/xeno.c index 0496d96044..ef48583eb9 100644 --- a/xenolinux-2.4.21-sparse/fs/partitions/xeno.c +++ b/xenolinux-2.4.21-sparse/fs/partitions/xeno.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -21,57 +22,57 @@ int xeno_partition(struct gendisk *hd, int first_part_minor) { physdisk_probebuf_t *buf; - int i; - int minor; - int count; + int i, minor; - buf = kmalloc(sizeof(*buf), GFP_KERNEL); - if (!buf) + /* Privileged domains can read partition info themselves. */ + if (start_info.flags & SIF_PRIVILEGED) + return 0; + + /* This only deals with raw/direct devices (IDE & SCSI). */ + switch ( xldev_to_physdev(bdev->bd_dev) & XENDEV_TYPE_MASK ) + { + case XENDEV_IDE: + case XENDEV_SCSI: + break; + default: + return 0; + } + + if ( (buf = kmalloc(sizeof(*buf), GFP_KERNEL)) == NULL ) return -ENOMEM; + buf->domain = start_info.dom_id; buf->start_ind = 0; buf->n_aces = PHYSDISK_MAX_ACES_PER_REQUEST; xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (char *)buf, sizeof(*buf)); - if (buf->n_aces == 0) { - kfree(buf); - return 0; - } - if (buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST) { - kfree(buf); - return 0; - } - - count = 0; + if ( buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST ) + printk(KERN_ALERT "Too many returns for xeno partition parser\n"); - for (i = 0; i < buf->n_aces; i++) { - if (buf->entries[i].partition == 0) { + for ( i = 0; i < buf->n_aces; i++ ) + { + if (buf->entries[i].partition == 0) continue; - } - /* Make sure the partition is actually supposed to be on this - disk. */ - if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev)) { + if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev)) continue; - } - /* This is a bit of a hack - the partition numbers are - specified by the hypervisor, and if we want them to match - up, this is what we need to do. */ - count ++; + if (!(buf->entries[i].mode & PHYSDISK_MODE_W)) + { + if (!(buf->entries[i].mode & PHYSDISK_MODE_R)) + continue; + set_device_ro(bdev->bd_dev, 1); + } minor = buf->entries[i].partition + first_part_minor - 1; add_gd_partition(hd, minor, buf->entries[i].start_sect, buf->entries[i].n_sectors); } - kfree(buf); - /* If we didn't find any suitable Xeno partitions, try the other - types. */ - if (!count) - return 0; + kfree(buf); printk("\n"); + return 1; } -- 2.30.2